<template>
  <a-select
    v-model:value="val"
    style="width: 120px"
    ref="select"
    @change="change"
    :disabled="isDisabled"
  >
    <a-select-option
      v-for="item of options"
      :key="item.value"
      :value="item.value"
      >{{ item.label }}</a-select-option
    >
  </a-select>
</template>

<script>
import { ref } from "@vue/reactivity";
export default {
  props: {
    currentVal: {
      //当前选中值
      type: String,
      required: true,
    },
    options: {
      //选项
      type: Array,
      required: true,
    },
    isDisabled: {
      //是否禁用
      type: Boolean,
      default: false,
    },
  },
  setup(props, { emit }) {
    // 响应式数据
    const val = ref(props.currentVal);

    // 双向绑定数据
    const change = (value) => {
      emit("update:currentVal", value);
    };
    return {
      val,
      change,
    };
  },
};
</script>

<style>
</style>